<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>单击显示数据</button>
</body>
</html>
<script>
    let btn=document.querySelector('button')
    btn.onclick=function(){
        // const xhr=new XMLHttpRequest()
        // xhr.open('get','http://localhost:3000/goods/getGoods?id=1')
        // xhr.onreadystatechange=function(){
        //     if(xhr.readyState===4&&xhr.status===200) {
        //         console.log(xhr.responseText);
        //     }
        // }
        // xhr.send()
        fetch('http://localhost:3000/goods/getGoods?id=1')
        .then(res=>res.json())
        .then(res=>console.log(res))
    }
</script>